﻿using LightSO.CMS.ServiceUser;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;


namespace LightSO.CMS.Controllers
{
    public class HomeController : BaseController
    {

        public ActionResult Index()
        {
            return View();
        }


        public ActionResult Home()
        {
            ViewBag.LoginName = base.LoginName;

            return View();
        }


        public ActionResult North()
        {
            ViewBag.UserId = base.UserId;
            ViewBag.LoginName = base.LoginName;
            return View();
        }


        public ActionResult West()
        {
            return View();
        }


        public ActionResult South()
        {
            return View();
        }

        /// <summary>
        /// 登录页面
        /// </summary>
        /// <returns></returns>
        public ActionResult Login()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Login(ServiceUser.User account, string ReturnUrl)
        {
            var client = new ServiceUser.User1Client();
            //用户登录
            var result = client.Login(account.LoginName, account.Password);
            if (!result)
            {
                return View(result);
            }
            else
            {
                if (string.IsNullOrWhiteSpace(ReturnUrl))
                    return RedirectToAction("index");
                else
                    Redirect(ReturnUrl);
            }
            return Json(result);
        }

        /// <summary>
        /// 退出系统
        /// </summary>
        /// <returns></returns>
        public ActionResult LoginOut()
        {
            FormsAuth.SignOut();
            return RedirectToAction("login");
        }
    }
}